#include <stdio.h>
void find_closest_flight(int desired_time, int *departure_time, int *arrival_time);
int main(void)
{
    int hh, mm;
    printf("Enter a 24-hour time: ");
    scanf("%d:%d", &hh, &mm);
    int stamp = hh * 60 + mm;
    int departure, arriving;
    find_closest_flight(stamp, &departure, &arriving);
    printf("Closet departure time is %d:%02d, arriving at %d:%02d\n", departure / 60, departure % 60, arriving / 60, arriving % 60);
    return 0;
}
void find_closest_flight(int desired_time, int *departure_time, int *arrival_time) {
    if (desired_time < 8 * 60) {
        *departure_time = 8 * 60;
        *arrival_time = 10 * 60 + 16;
    }
    else if (desired_time < 9 * 60 + 43) {
        *departure_time = 9 * 60 + 43;
        *arrival_time = 11 * 60 + 52;
    }
    else if (desired_time < 11 * 60 + 19) {
        *departure_time =  11 * 60 + 19;
        *arrival_time = 13 * 60 + 31;
    }
    else if (desired_time < 12 * 60 + 47) {
        *departure_time = 12 * 60 + 47;
        *arrival_time = 15 * 60;
    }
    else if (desired_time < 14 * 60) {
        *departure_time =  14 * 60;
        *arrival_time = 16 * 60 + 8;
    }
    else if (desired_time < 15 * 60 + 45) {
        *departure_time = 15 * 60 + 45;
        *arrival_time = 17 * 60 + 55;
    }
    else if (desired_time < 19 * 60) {
        *departure_time = 19 * 60;
        *arrival_time = 21 * 60 + 20;
    }
    else if (desired_time < 21 * 60 + 45) {
        *departure_time = 21 * 60 + 45;
        *arrival_time = 23 * 60 + 55;
    }
    else {
        *departure_time = 8 * 60;
        *arrival_time = 10 * 60 + 16;
    }
}